home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 6.1 KB | 247 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWDbgStr.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWENVDEF_H
- #include "FWEnvDef.h"
- #endif
-
- #if !defined(FWDBGSTR_H) && defined(FW_DEBUG)
- #define FWDBGSTR_H
-
- #include <stddef.h>
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #ifdef FW_BUILD_WIN
- #include <Windows.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // CLASS FW_CDebugStream
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CDebugStream
- {
- public:
- typedef FW_CDebugStream& (*Manipulator)(FW_CDebugStream &);
-
- friend FW_FUNC_ATTR FW_CDebugStream& EndLine(FW_CDebugStream &);
-
- FW_CDebugStream();
- virtual ~FW_CDebugStream();
- // Destructor
-
- virtual FW_CDebugStream &Write(const void *data, size_t size) = 0;
- // Does the raw write of the data without any data separator
-
- FW_CDebugStream &WriteChunk(const void *data, size_t size);
- // Write raw data with a data separator
-
- FW_CDebugStream &operator<<(Manipulator function);
- // Execute the manipulator
-
-
- FW_CDebugStream &operator<<(const char *string);
- // Write null terminated char string
-
- FW_CDebugStream &operator<<(const signed char *string);
- // Write null terminated string
-
- FW_CDebugStream &operator<<(const unsigned char *string);
- // Write null terminated string
-
-
- FW_CDebugStream &operator<<(char c);
- // Write character
-
- FW_CDebugStream &operator<<(signed char c);
- // Write signed character
-
- FW_CDebugStream &operator<<(unsigned char c);
- // Write unsigned character
-
- FW_CDebugStream &operator<<(short n);
- // Write short
-
- FW_CDebugStream &operator<<(int n);
- // Write int
-
- FW_CDebugStream &operator<<(long n);
- // Write long
-
- FW_CDebugStream &operator<<(unsigned short n);
- // Write unsigned short
-
- FW_CDebugStream &operator<<(unsigned n);
- // Write unsigned
-
- FW_CDebugStream &operator<<(unsigned long n);
- // Write unsigned long
-
- FW_CDebugStream &operator<<(void *);
- // Write address in hex
-
- protected:
- FW_CDebugStream & WriteBase10Number(long n);
- // Write long in base 10
-
- FW_CDebugStream & WriteBase16Number(unsigned long n);
- // Write unsigned long in base 16
-
- private:
- FW_CDebugStream(const FW_CDebugStream& debugStream);
- FW_CDebugStream& operator=(const FW_CDebugStream& debugStream);
- // Don't copy instances of this class.
- };
-
-
- inline FW_CDebugStream &FW_CDebugStream::operator<<(Manipulator function)
- {
- return function(*this);
- }
-
- inline FW_CDebugStream & FW_CDebugStream::operator<<(const char *string)
- {
- return operator<<((const signed char *) string);
- }
-
- inline FW_CDebugStream & FW_CDebugStream::operator<<(const unsigned char *string)
- {
- return operator<<((const signed char *) string);
- }
-
- inline FW_CDebugStream & FW_CDebugStream::operator<<(char c)
- {
- return operator<<((signed char) c);
- }
-
- inline FW_CDebugStream & FW_CDebugStream::operator<<(unsigned char c)
- {
- return operator<<((signed char) c);
- }
-
- inline FW_CDebugStream & FW_CDebugStream::operator<<(short n)
- {
- return operator<<((long) n);
- }
-
- inline FW_CDebugStream & FW_CDebugStream::operator<<(int n)
- {
- return operator<<((long) n);
- }
-
- inline FW_CDebugStream & FW_CDebugStream::operator<<(unsigned short n)
- {
- return operator<<((unsigned long) n);
- }
-
- inline FW_CDebugStream & FW_CDebugStream::operator<<(unsigned n)
- {
- return operator<<((unsigned long) n);
- }
-
-
- //========================================================================================
- // CLASS EndLine
- //========================================================================================
-
- FW_FUNC_ATTR FW_CDebugStream& EndLine(FW_CDebugStream &);
- // Output end of line character or characters depending on platform
-
- //========================================================================================
- // CLASS FW_CBufferDebugStream
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CBufferDebugStream : public FW_CDebugStream
- {
- public:
- virtual ~FW_CBufferDebugStream();
- FW_CBufferDebugStream(void * buffer, size_t bufferSize);
- // Constructor
-
- virtual FW_CDebugStream &Write(const void *data, size_t size);
- // Write data
-
- private:
- const void * fBuffer;
- // FW_SPlatformPoint to data buffer
-
- const size_t fBufferSize;
- // Size of buffer
-
- size_t fPosition;
- // Next position to write to in buffer
-
- FW_CBufferDebugStream(const FW_CBufferDebugStream& debugStream);
- FW_CBufferDebugStream& operator=(const FW_CBufferDebugStream& debugStream);
- // Don't copy instances of this class.
- };
-
-
- //========================================================================================
- // CLASS FW_CNullDebugStream
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CNullDebugStream : public FW_CDebugStream
- {
- public:
- FW_CNullDebugStream();
- virtual ~FW_CNullDebugStream();
-
- virtual FW_CDebugStream &Write(const void *data, size_t size);
- // Write data
-
- private:
- FW_CNullDebugStream(const FW_CNullDebugStream& debugStream);
- FW_CNullDebugStream& operator=(const FW_CNullDebugStream& debugStream);
- // Don't copy instances of this class.
- };
-
-
- //========================================================================================
- // CLASS FW_CFileDebugStream
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CFileDebugStream : public FW_CDebugStream
- {
- public:
- FW_CFileDebugStream(char *fileName);
- // Constructor
-
- ~FW_CFileDebugStream();
- // Destructor
-
- virtual FW_CDebugStream &Write(const void *data, size_t size);
- // Write data
-
- private:
- #ifdef FW_BUILD_MAC
- short fMacFileNumber;
- #endif
- #ifdef FW_BUILD_WIN
- HFILE fWinFileHandle;
- #endif
-
- FW_CFileDebugStream(const FW_CFileDebugStream& debugStream);
- FW_CFileDebugStream& operator=(const FW_CFileDebugStream& debugStream);
- // Don't copy instances of this class.
- };
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-